## 寻找不一样的标签或者图片
import os

# 指定图片和标签文件夹路径
img_folder = r'/home/shuai/Documents/mydataset/my_usv_aug/VOCdevkit/JPEGImages'
labels_folder = r'/home/shuai/Documents/mydataset/my_usv_aug/VOCdevkit/Annotations'

# 获取图片文件名并提取序号
img_files = [f for f in os.listdir(img_folder) if f.endswith('.jpg')]
img_numbers = set(f.split('.')[0] for f in img_files)

# 获取标签文件名并提取序号
label_files = [f for f in os.listdir(labels_folder) if f.endswith('.xml')]
label_numbers = set(f.split('.')[0] for f in label_files)

# 找出在图片文件夹中有但标签文件夹中缺失的序号
missing_files_label = img_numbers - label_numbers
missing_files_img = img_numbers - label_numbers

# 输出缺失的标签序号
if missing_files_label:
    print("缺失的标签文件:", missing_files_label)
else:
    print("所有标签文件都存在，没有缺失的。")

print("#####################################")

if missing_files_img:
    print("缺失的图片文件:", missing_files_img)
else:
    print("所有图片文件都存在，没有缺失的。")
